"use strict";

/**
 * @ngdoc directive
 * @name jgappApp.directive:checkuserDefine
 * @description
 * # checkuserDefine
 */
angular.module("jgappApp").directive("checkuserDefine", function(OpenFile) {
  return {
    scope: {
      fieldMap: "=fieldMap"
    },
    restrict: "AE",
    templateUrl: "views/userdefined/check_usertemp.html",
    replace: true,
    link: function postLink(scope, element, attrs) {
      var init = function() {
        // 如果是审批页面只做展示
        scope.$watch("fieldMap", function(newValue, oldValue) {
          if (scope.fieldMap) {
            var fieldMapObj = JSON.parse(scope.fieldMap);
            scope.formData = angular.extend(fieldMapObj, {});
          }
        });
        
        scope.hrefLink = function(href) {
          // ios & android are opened in the different way
          OpenFile.showFile(href)
        };
      };
      init();
    }
  };
});
